<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="70px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-4">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      (click)="jumpPage(0)"
    >新增商品标签</button>
  </div>

  <div class="pagination-wrap-position p-t-10">
    <nz-table
      #basicTable
      nzTableLayout="fixed"
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="100px" nzLeft>ID</th>
          <th nzAlign="center" nzWidth="120px">状态</th>
          <th nzAlign="center" nzWidth="180px">标题</th>
          <th nzAlign="center" nzWidth="180px">样式</th>
          <th nzAlign="center" nzWidth="200px">参数</th>
          <!-- <th nzAlign="center" nzWidth="150px">业务</th> -->
          <th nzAlign="center" nzWidth="120px">类型</th>
          <th nzAlign="center" nzWidth="120px">关联ID</th>
          <th nzAlign="center" nzWidth="220px">适用场景</th>
          <th nzAlign="center" nzWidth="120px">适用用户</th>
          <th nzAlign="center" nzWidth="300px">生效时间</th>
          <th nzAlign="center" nzWidth="150px" nzRight>操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- ID -->
          <td nzAlign="center" nzLeft>{{ data.id }}</td>
          <!-- 状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.status === 1 ? '#67C23A' : '#F56C6C'}">
              {{ data.status === 1 ? '启用' : '禁用' }}
            </span>
          </td>
          <!-- 标题 -->
          <td nzAlign="center">{{ data.name || '-' }}</td>
          <!-- 样式 -->
          <td nzAlign="center">{{ getGoodsStyleText(data.styleTag) }}</td>
          <!-- 参数 -->
          <td nzAlign="center">{{ data.params || '-' }}</td>
          <!-- 业务 -->
          <!-- <td nzAlign="center">回收</td> -->
          <!-- 类型 -->
          <td nzAlign="center">
            <ng-container [ngSwitch]="data.type">
              <span *ngSwitchCase="1">自定义</span>
              <span *ngSwitchCase="2">优惠券</span>
              <span *ngSwitchCase="3">直降促销</span>
              <span *ngSwitchDefault>-</span>
            </ng-container>
          </td>
          <!-- 关联ID -->
          <td nzAlign="center">{{ data.businessId }}</td>
          <!-- 适用场景 -->
          <td nzAlign="center">
            {{ getUseSceneText(data.useScene) }}
          </td>
          <!-- 适用用户 -->
          <td nzAlign="center">
            <ng-container [ngSwitch]="data.userType">
              <nz-tag *ngSwitchCase="0">通用</nz-tag>
              <nz-tag *ngSwitchCase="1" [nzColor]="'#87d068'">C端</nz-tag>
              <nz-tag *ngSwitchCase="2" [nzColor]="'#2db7f5'">B端</nz-tag>
              <span *ngSwitchDefault>-</span>
            </ng-container>
          </td>
          <!-- 生效时间 -->
          <td nzAlign="center">
            <ng-container *ngIf="data.getBeginTime;else templateTm">
              {{ data.getBeginTime }} ~ {{ data.getEndTime }}
            </ng-container>
            <ng-template #templateTm>-</ng-template>
          </td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <a
              nz-button
              nzType="link"
              nzSize="small"
              (click)="jumpPage(1, data)"
            >查看</a>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>